package com.example.design.bilibili.factory.simpleFactory;

public class SimpleFactory {

    public Pizza createPizza(String orderType){
        Pizza pizza = null;
        if(OrderType.GREEK.equals(orderType)){
            pizza = new GreekPizza();
            pizza.setName("希腊披萨");
        }else if(OrderType.CHEESE.equals(orderType)){
            pizza = new CheesePizza();
            pizza.setName("奶酪披萨");
        }else if(OrderType.CHINA.equals(orderType)){
            pizza = new ChinaPizza();
            pizza.setName("中国披萨");
        }

        return pizza;
    }

    //简单工厂模式 也叫 静态工厂模式

    public static Pizza createPizza2(String orderType) {

        Pizza pizza = null;

        System.out.println("使用简单工厂模式2");
        if (orderType.equals("greek")) {
            pizza = new GreekPizza();
            pizza.setName(" 希腊披萨 ");
        } else if (orderType.equals("cheese")) {
            pizza = new CheesePizza();
            pizza.setName(" 奶酪披萨 ");
        } else if (orderType.equals("china")) {
            pizza = new ChinaPizza();
            pizza.setName("中国披萨");
        }

        return pizza;
    }
}
